<template>
  <div class="app-container">
    <el-tabs v-model="activeName" type="card" @tab-remove="removeTab" @tab-click="tabclick">
      <el-tab-pane label="在用设备" name="1">
        <template v-if="activeName === '1'">
          <Reuse ref="iscond"></Reuse>
        </template>
      </el-tab-pane>
      <el-tab-pane label="已报废设备" name="2">
        <template v-if="activeName === '2'">
          <Scrapped></Scrapped>
        </template>
      </el-tab-pane>
      <el-tab-pane label="已变卖设备" name="3">
        <template v-if="activeName === '3'">
          <SellOff></SellOff>
        </template>
      </el-tab-pane>
      <el-tab-pane label="位置管理" name="4">
        <template v-if="activeName === '4'">
          <Location></Location>
        </template>
      </el-tab-pane>
      <el-tab-pane label="盘亏设备" name="5">
        <template v-if="activeName === '5'">
          <Loss></Loss>
        </template>
      </el-tab-pane>
      <template v-if="tabIndex">
        <el-tab-pane label="设备详情" name="6" closable>
          <template v-if="activeName === '6'">
            <SubsetContent :rowObj="rowObj"></SubsetContent>
          </template>
        </el-tab-pane>
      </template>
    </el-tabs>
  </div>
</template>

<script>
export default {
  name: "ledger",
  // dicts: ['sys_notice_status', 'sys_notice_type'],
  components: {
    Reuse: () => import('./reuse/index.vue'),//再用设备
    Scrapped: () => import('./scrapped/index.vue'),//已报废设备
    SellOff: () => import('./selloff/index.vue'),//已变卖设备
    Location: () => import('./Location/index.vue'),//位置管理
    Loss: () => import('./loss/index.vue'),//盘亏设备
    SubsetContent: () => import('./SubsetContent.vue'),//盘亏设备
  },
  data () {
    return {
      activeName: '1',
      tabIndex: false,
      rowObj: {}
    };
  },
  watch: {
  },
  computed: {
    isCondition: {
      get () {
        return this.$store.state.user.isCondition
      }
    },

  },
  created () {
    // this.activeName = this.isCondition
    if (this.isCondition === '2') {
      setTimeout(() => {
        this.$refs['iscond'].$refs['reusereftable'].getList({ status: this.$route.query.status });
      }, 500);
    }
  },
  methods: {
    tabclick () {
      if (this.activeName === '6') {
        return
      }
      this.tabIndex = false
      this.rowObj = {}
    },
    removeTab () {
      this.tabIndex = false
      this.activeName = '1'
    },
    // addTab(row){
    //   this.tabIndex = true
    //   this.activeName = '3'
    //   this.rowObj = row
    // }
  }
};
</script>
